package br.com.bringme.views;

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import java.awt.Component;

@SuppressWarnings("serial")
public class BuscarCliente extends JFrame {

	private JPanel contentPane;
	private JTextField tfTelefoneCliente;
	private JTextField tfNomeCliente;
	private JButton btnSelecionar;
	private JButton btnInformacoes;
	private JTable tbClientes;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					BuscarCliente frame = new BuscarCliente();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public BuscarCliente() {
		setResizable(false);
		setTitle("BringMe - Buscar Cliente");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 473, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JLabel lblClienteTelefone = new JLabel("Telefone do Cliente:");
		lblClienteTelefone
				.setFont(new Font("Century Gothic", Font.PLAIN, 12));
		lblClienteTelefone.setBounds(10, 11, 127, 14);
		contentPane.add(lblClienteTelefone);

		JLabel lblClienteNome = new JLabel("Nome do Cliente:");
		lblClienteNome.setFont(new Font("Century Gothic", Font.PLAIN, 12));
		lblClienteNome.setBounds(10, 36, 109, 14);
		contentPane.add(lblClienteNome);

		tfTelefoneCliente = new JTextField();
		tfTelefoneCliente.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		tfTelefoneCliente.setBounds(147, 9, 170, 20);
		contentPane.add(tfTelefoneCliente);
		tfTelefoneCliente.setColumns(10);

		tfNomeCliente = new JTextField();
		tfNomeCliente.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		tfNomeCliente.setBounds(147, 34, 307, 20);
		contentPane.add(tfNomeCliente);
		tfNomeCliente.setColumns(10);

		JButton btnBuscar = new JButton("Buscar");
		btnBuscar.setFont(new Font("Century Gothic", Font.PLAIN, 12));
		btnBuscar.setIcon(new ImageIcon(BuscarCliente.class
				.getResource("/br/com/bringme/vision/icons/Search16.png")));
		btnBuscar.setBounds(327, 8, 127, 23);
		contentPane.add(btnBuscar);

		btnSelecionar = new JButton("Selecionar");
		btnSelecionar.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		btnSelecionar.setIcon(new ImageIcon(BuscarCliente.class
				.getResource("/br/com/bringme/vision/icons/Accept16.png")));
		btnSelecionar.setBounds(327, 65, 127, 23);
		contentPane.add(btnSelecionar);

		btnInformacoes = new JButton("Informa\u00E7\u00F5es");
		btnInformacoes.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		btnInformacoes.setIcon(new ImageIcon(BuscarCliente.class
				.getResource("/br/com/bringme/vision/icons/Info16.png")));
		btnInformacoes.setBounds(327, 99, 127, 23);
		contentPane.add(btnInformacoes);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setBounds(10, 61, 307, 200);
		contentPane.add(scrollPane);
		
		tbClientes = new JTable();
		tbClientes.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		tbClientes.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Nome", "Telefone"
			}
		) {
			@SuppressWarnings("rawtypes")
			Class[] columnTypes = new Class[] {
				String.class, String.class
			};
			@SuppressWarnings({ "rawtypes", "unchecked" })
			public Class getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
			boolean[] columnEditables = new boolean[] {
				false, false
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		tbClientes.getColumnModel().getColumn(0).setResizable(false);
		tbClientes.getColumnModel().getColumn(0).setPreferredWidth(150);
		tbClientes.getColumnModel().getColumn(0).setMinWidth(150);
		tbClientes.getColumnModel().getColumn(0).setMaxWidth(150);
		tbClientes.getColumnModel().getColumn(1).setResizable(false);
		tbClientes.getColumnModel().getColumn(1).setPreferredWidth(150);
		tbClientes.getColumnModel().getColumn(1).setMinWidth(150);
		tbClientes.getColumnModel().getColumn(1).setMaxWidth(150);
		scrollPane.setViewportView(tbClientes);
		
		JButton btnCancelar = new JButton("Cancelar");
		btnCancelar.setIcon(new ImageIcon(BuscarCliente.class.getResource("/br/com/bringme/vision/icons/Cancel16.png")));
		btnCancelar.setFont(new Font("Century Gothic", Font.PLAIN, 11));
		btnCancelar.setBounds(327, 133, 127, 23);
		contentPane.add(btnCancelar);
		setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{tfTelefoneCliente, tfNomeCliente, btnBuscar, tbClientes, btnSelecionar, btnInformacoes, btnCancelar}));
	}
}
